<template>
	<div>
		<el-form :label-width="language == 'en' ? '130px' : '100px'">
			<el-form-item :label="$t('account.account.name') + ':'" prop="nickname" class="pr-8">
				<el-input v-model="info.nickname" disabled />
			</el-form-item>

			<el-form-item :label="$t('account.account.login') + ':'" prop="account" class="pr-8">
				<el-input v-model="info.account" disabled />
			</el-form-item>

			<el-form-item :label="$t('account.account.loginPass') + ':'" prop="password" class="pr-8">
				<el-input v-model="info.password" :show-password="true" type="password" :placeholder="$t('message.enterPass')" />
			</el-form-item>


			<el-form-item :label="$t('account.account.confirmPass') + ':'" prop="passwords" class="pr-8">
				<el-input v-model="info.passwords" :show-password="true" type="password" :placeholder="$t('message.enterPassAgain')" />
			</el-form-item>

			<el-form-item>
				<div class="w-9/12 text-center">
					<el-button type="primary" @click="submit">{{ $t('public.save') }}</el-button>
					<el-button @click="cancel">{{ $t('public.cancel') }}</el-button>
				</div>
			</el-form-item>

		</el-form>
	</div>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n' 
const { t: $t } = useI18n()
import { onMounted } from 'vue'
let language = ref()
const { locale } = useI18n()
onMounted(() => {
	language.value = locale.value
})
let emit = defineEmits(['investigate'])

let props = defineProps({
	info: {
		type: Object,
		default: {}
	}
})

// 提交
let submit = () => {

	let status = false
	if (props.info.password == '' || props.info.passwords == '') {
		ElMessage({
			message: $t('message.pleasePass'),
			type: 'error'
		})
		return
	}

	if (props.info.password === props.info.passwords) {
		status = true
	}

	if (!status) {
		ElMessage({
			message: $t('message.passSync'),
			type: 'error'
		})
		return
	}

	let obj = {
		manager_id: props.info.manager_id,
		password: props.info.password
	}
	emit('investigate', obj)
}

// 取消
let cancel = () => {
	emit('investigate', false)
}

</script>